import {
  TODO_ADD,
  TODO_DEL_BY_ID,
  TODO_UPDATE_BY_ID,
  TODO_UPDATE_TYPE,
} from './actionTypes';

export const delByIdAction = (id) => ({
  type: TODO_DEL_BY_ID,
  payload: id,
});

export const updateByIdAction = (payload) => ({
  type: TODO_UPDATE_BY_ID,
  payload,
});

export const addAction = (task) => {
  const newItem = {
    task: task,
    id: Date.now(),
    isDone: false,
  };
  return {
    type: TODO_ADD,
    payload: newItem,
  };
};

export const updateTypeAction = (type) => ({
  type: TODO_UPDATE_TYPE,
  payload: type,
});
